import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [{
    path: "/",
    redirect: "/home",
  },
  {
    path: "/login",
    component: () => import("../components/Login"),
  },
  {
    path: "/home",
    component: () => import("../components/Home"),
    redirect: "/welcome",
    children: [{
        path: "/welcome",
        component: () => import("../components/Welcome"),
      },
      {
        path: "/system",
        component: () => import("../components/system/Property"),
      },
      {
        path: "/state",
        component: () => import("../components/state/FireWallState"),
      },
      {
        path:"/SoftEther",
        component:()=>import("../components/VPN/SoftEtherVPN.vue")
      },
      {
        path:"/OpenVPN",
        component:()=>import("../components/VPN/OpenVPN.vue")
      },
      {
        path:"/IPSecVPN",
        component:()=>import("../components/VPN/IPSecVPN.vue")
      },
      {
        path:"/Zero Tier",
        component:()=>import("../components/VPN/Zero Tier.vue")
      },
      {
        path: "/guide",
        component: () => import("../components/guide/guide.vue"),
      },
      {
        path: "/flowControl",
        component: () => import("../components/control/flowControl"),
      },
      {
        path: "/CPUControl",
        component: () => import("../components/control/CPUControl"),
      },
      {
        path: "/MapControl",
        component: () => import("../components/control/MapControl.vue"),
      },
      {
        path: "/MapControl2",
        component: () => import("../components/control/MapControl2.vue"),
      },
      {
        path:"/AI_Information",
        component:()=>import("../components/AI/Information.vue")
      },
      {
        path:"/AI_Interface",
        component:()=>import("../components/AI/Interface.vue")
      },
      {
        path:"/AI_Monitor",
        component:()=>import("../components/AI/Monitor.vue")
      },
      {
        path:"/AI_Name",
        component:()=>import("../components/AI/Name.vue")
      },
      {
        path:"/P4_Information",
        component:()=>import("../components/P4/Information.vue")
      },
      {
        path:"/P4_Interface",
        component:()=>import("../components/P4/Interface.vue")
      },
      {
        path:"/P4_Monitor",
        component:()=>import("../components/P4/Monitor.vue")
      },
      {
        path:"/P4_Name",
        component:()=>import("../components/P4/Name.vue")
      },
      {
        path:"/FPGA_Information",
        component:()=>import("../components/FPGA/Information.vue")
      },
      {
        path:"/FPGA_Interface",
        component:()=>import("../components/FPGA/Interface.vue")
      },
      {
        path:"/FPGA_Monitor",
        component:()=>import("../components/FPGA/Monitor.vue")
      },
      {
        path:"/FPGA_Name",
        component:()=>import("../components/FPGA/Name.vue")
      },
      {
        path:"/coreLog",
        component:()=>import("../components/state/CoreLog.vue")
      },
      {
        path:"/information",
        component:()=>import("../components/state/Information.vue")
      },
      {
        path:"/monitor",
        component:()=>import("../components/state/Monitor.vue")
      },
      {
        path:"/overview",
        component:()=>import("../components/state/Overview.vue")
      },
      {
        path:"/routerTable",
        component:()=>import("../components/state/RouterTable.vue")
      },
      {
        path:"/systemLog",
        component:()=>import("../components/state/SystemLog.vue")
      },
      {
        path:"/systemProcess",
        component:()=>import("../components/state/SystemProcess.vue")
      },
      {
        path:"/backups",
        component:()=>import("../components/system/Backups.vue")
      },
      {
        path:"/diskManage",
        component:()=>import("../components/system/DiskManage.vue")
      },
      {
        path:"/managementPower",
        component:()=>import("../components/system/ManagementPower.vue")
      },
      {
        path:"/restart",
        component:()=>import("../components/system/Restart.vue")
      },
      {
        path:"/softwarePackage",
        component:()=>import("../components/system/SoftwarePackage.vue")
      },
      {
        path:"/startupItem",
        component:()=>import("../components/system/StartupItem.vue")
      },
      {
        path:"/TTYD",
        component:()=>import("../components/system/TTYD.vue")
      },
      {
        path:"/webManage",
        component:()=>import("../components/system/WebManage.vue")
      },
      {
        path:"/Test1",
        component:()=>import("../components/AI/Test1.vue")
      },
      {
        path:"/Test2",
        component:()=>import("../components/test/Test2.vue")
      },
      {
        path:"/Test3",
        component:()=>import("../components/test/Test3.vue")
      },
      {
        path:'/P4_Test1',
        component:()=>import("../components/P4/Test1.vue")
      },
      {
        path:'/Multi-Hop',
        component:()=>import('../components/test/Multi-Hop.vue')
      },
      {
        path:'/LoadBalancing',
        component:()=>import('../components/test/LoadBalancing.vue')
      },
      {
        path:'/SourceRoutingIdenify',
        component:()=>import('../components/test/SourceRoutingIdenify.vue')
      },
      {
        path:'/111',
        component:()=>import('../components/test/111.vue')
      }
      
    ],
  },
];

const router = new VueRouter({
  routes,
});
// router.beforeEach((to, from, next) => {
//   //next是一个函数，表示放行,必须使用next()
//   if (to.path == "/login") {
//     return next();

//     //如果是有权限的页面
//   } else {
//     const tokenStr = window.sessionStorage.getItem("token");
//     if (!tokenStr) {
//       return next("/login");
//     } else {
//       next();
//     }
//   }
// });
export default router;